<?php echo $this->render('./includes/header.phtml');?>
<?php echo $this->render('./includes/fix_top_menu.phtml');?>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<?php if(count($this->arrLocInfo) != 0) {?>
<script type="text/javascript">
/* Code based on Google Map APIv3 Tutorials */
var gmapdata;
var gmapmarker;
var infoWindow;

var def_zoomval = 15;
var def_longval = <?php echo $this->arrLocInfo[0]['longitude'];?>;
var def_latval = <?php echo $this->arrLocInfo[0]['latitude'];?>;

function initialize()
{
	// init for Map
	var curpoint = new google.maps.LatLng(def_latval,def_longval);

	gmapdata = new google.maps.Map(document.getElementById("mapitems"), {
		center: curpoint,
		zoom: def_zoomval,
		mapTypeId: 'roadmap'
		});

	gmapmarker = new google.maps.Marker({
					map: gmapdata,
					position: curpoint
				});

	infoWindow = new google.maps.InfoWindow;
	google.maps.event.addListener(gmapdata, 'click', function(event) {
		document.getElementById("longval").value = event.latLng.lng().toFixed(7);
		document.getElementById("latval").value = event.latLng.lat().toFixed(7);
		gmapmarker.setPosition(event.latLng);
	});

	google.maps.event.addListener(gmapmarker, 'click', function() {
		infoWindow.open(gmapdata, gmapmarker);
	});

	document.getElementById("longval").value = def_longval;
	document.getElementById("latval").value = def_latval;

	return false;
} // end of if_gmap_init

google.maps.event.addDomListener(window, 'load', initialize);

</script>
<?php }?>
	<div id="container" class="row-fluid">
		<?php echo $this->render('./includes/menu.phtml');?>
		<div id="main-content">
			<div class="container-fluid">
				<div class="row-fluid">
					<div class="span12">
						<h3 class="page-title">
							Quản lí địa điểm  <small>Chinh sửa </small>
						</h3>
					</div>
				</div>
							<div class="row-fluid">
					<div class="span12">
						<div class="widget">
							<div class="widget-title">
								<h4>
									<i class="icon-reorder"></i>Tổng số địa điểm : <?php echo $this->total_location;?>
								</h4>
								<div class="pull-right span3">
								<a href="<?php echo $this->baseUrl('/location/')?>" class="btn span12 pull-right" style="margin-top: 3px; margin-right: 3px;"> <i class="icon-circle-arrow-left icon-white"></i>  Danh sách địa điểm </a>
								</div>
							</div>
							
							<div class="widget-body">
								<?php echo $this->render('./includes/display_alert_message.phtml');?>
								<?php if(count($this->arrLocInfo) != 0) {?>
								<form action="" class="form-horizontal" method="post" enctype="multipart/form-data">
								<div class="control-group">
								<label class="control-label">Tên  :</label>
								<div class="controls"><input type="text" name="location_name" value="<?php echo $this->arrLocInfo[0]['name'];?>"/></div>
								</div>
								<div class="control-group">
								<label class="control-label">Tỉnh/Thành phố  :</label>
								<div class="controls">
								<?php 
								if(count($this->arrListCity) != 0) {
								?>
									<select name="cbCity">
											<?php foreach ($this->arrListCity as $city) {?>
											<option value="<?php echo $city['city_id'];?>" <?php echo $this->arrLocInfo[0]['city_id'] == $city['city_id'] ? 'selected="selected"' : "";?>><?php echo $city['name'];?></option>
											<?php }?>
										</select>
								<?php 
								}
								?>
								</div>
								</div>
								<div class="control-group">
								<label class="control-label">Bản đồ  :</label>
								<div class="controls">
									<input type="hidden" value="<?php echo $this->arrLocInfo[0]['location_id'];?>" name="location_id">
									<input type="hidden" value="" id="longval" name="longval">
									<input type="hidden" value="" id="latval" name="latval">
								<p><small>Click vào bản đồ để đánh dấu vị trí địa điểm</small></p>
								<div class="map-frame" id="mapitems"
									style="display: block; width: 100%; height: 300px;">
								</div>
								</div>
								</div>
								<?php if(count($this->arrPhoto) != 0) {?>
								
								<div class="control-group">
								<label class="control-label">Ảnh  :</label>
								<div class="controls">
									<div class="span3">
											<div class="thumbnail">
												<div class="item">
													<a class="fancybox-button" data-rel="fancybox-button"
														title="" href="<?php echo $this->baseUrl(UPLOAD_PHOTO_DIRECTORY.$this->arrPhoto[0]['photo_link']);?>"><div
															class="zoom">
															<img src="<?php echo $this->baseUrl(UPLOAD_PHOTO_DIRECTORY.$this->arrPhoto[0]['photo_link']);?>" alt="" />
															<div class="zoom-icon"></div>
														</div></a>
												</div>
											</div>
									</div>
									<div class="span9">
										<input type="hidden" name="photo_id" value="<?php echo $this->arrPhoto[0]['photo_id'];?>" />
										<p><small>Upload ảnh mới </small></p>
										<input type="file" name="picture"/>
									</div>
								</div>
								</div>
								<?php }?>
								
								<div class="control-group">
								<label class="control-label">Mô tả  :</label>
								<div class="controls">
								<textarea class="span12" rows="5" cols="" name="description"><?php echo $this->arrLocInfo[0]['description'];?></textarea>
								</div>
								</div>
								
								<div class="form-actions">
								<button type="submit" class="btn btn-primary" name="btnEdit">
								<i class="icon-ok"> </i>
								Lưu 
								</button>
								<button type="reset" class="btn">
								<i class=" icon-remove"> </i>
								Nhập lại 
								</button>
								</div>
								</form>
								<?php }?>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php echo $this->render('./includes/footer.phtml');?>